package com.expense.app.admin.controller;

import cn.hutool.log.Log;
import cn.hutool.log.LogFactory;
import com.expense.app.admin.annotation.OpeLog;
import com.expense.app.admin.model.params.adminMenu.AdminMenuDetailParam;
import com.expense.app.admin.model.params.adminUser.AdminUserDetailSaveParam;
import com.expense.app.admin.services.AdminMenuServ;
import com.expense.common.entity.params.DetailParam;
import com.expense.common.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping(value = "/adminMenu")
public class AdminMenuCtrl {
    private static final Log log = LogFactory.get();

    @Autowired
    AdminMenuServ adminMenuServ;

    @RequestMapping(value = "/findList",method = RequestMethod.GET)
    public Result findList() {
        return Result.success(adminMenuServ.findList());
    }

    @RequestMapping(value = "/{id}",method = RequestMethod.GET)
    public Result findDetail (@Validated DetailParam param) {
        return Result.success(adminMenuServ.findDetail(param));
    }

    @RequestMapping(value = "/save",method = RequestMethod.POST)
    @OpeLog(type = "菜单管理",value = "保存菜单信息")
    public Result saveOne(@Validated @RequestBody AdminMenuDetailParam param) {
        return Result.success(adminMenuServ.saveOne(param));
    }

    @RequestMapping(value = "/{id}",method = RequestMethod.DELETE)
    @OpeLog(type = "菜单管理",value = "删除菜单")
    public Result deleted(@Validated DetailParam param) {
        return Result.success(adminMenuServ.deleted(param));
    }



}
